package com.lwq.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.MatteBorder;

import com.lwq.util.DrawUtil;



public class DesignView extends FrameView{
	private final static int mFrameWidth = 800;
	private final static int mFrameHeight = 600;
	
	private final static int mLeftWidth = 200;
	private final static int mRightWidth = 200;
	
	private final static int mTopHeight = 100;
	private final static int mBottomHeight = 100;
	
	
	
	private Color mFrameColor = new Color(0xFAEBD7);
	private Color mCenterbgColor = new Color(0xF0F8FF);
	private MenuView mMenuBar = null;
	
	private JPanel mPanelNorth = null;
	private JScrollPane mPanelEast = null;
	private JScrollPane mPanelWest = null;
	private JPanel mPanelSouth = null;
	private JScrollPane mPanelCenter = null;
	private LeftEditorView mLeftEditorView = null;
	private RightEditorView mRightEditorView = null;
	private CenterEditorView mCenterEditorView = null;
	
	private static DesignView instance = null;
	
	public static DesignView getInstance(){
		if(instance == null){
			instance = new DesignView();
		}
		return instance;
	}
	
	
	public DesignView() {
		super("MainMenu", mFrameWidth, mFrameHeight);
		init();
		setEvent();
		DrawUtil.refreshScreen(this);
	}
	
	private void init(){
		
		mMenuBar = new MenuView();
		setMenuBar(mMenuBar);
		mPanelNorth = new JPanel();
		mPanelEast = new JScrollPane();
		mPanelWest = new JScrollPane();
		mPanelSouth = new JPanel();
		mPanelCenter = new JScrollPane();
		
		mPanelNorth.setBorder(new MatteBorder(0, 0, 2, 0, Color.lightGray));
		mPanelEast.setBorder(new MatteBorder(0, 2, 0, 2, Color.lightGray));
		mPanelWest.setBorder(new MatteBorder(0, 2, 0, 2, Color.lightGray));
		mPanelSouth.setBorder(new MatteBorder(2, 2, 2, 2, Color.lightGray));
		mPanelCenter.setBorder(new MatteBorder(0, 2, 2, 2, Color.lightGray));
		
		mPanelNorth.setVisible(true);
		mPanelEast.setVisible(true);
		mPanelWest.setVisible(true);
		mPanelSouth.setVisible(true);
		mPanelCenter.setVisible(true);
		
		mPanelNorth.setBackground(mFrameColor);
		mPanelEast.setBackground(mFrameColor);
		mPanelWest.setBackground(mFrameColor);
		mPanelSouth.setBackground(mFrameColor);
//		mPanelCenter.setBackground(mFrameColor);
		
		add(mPanelNorth, "North");
		add(mPanelWest, "West");
		add(mPanelEast, "East");
		add(mPanelSouth, "South");
//		add(mPanelCenter, "Center");
		
		mPanelNorth.setPreferredSize(new Dimension(mFrameWidth, 2));
		mPanelEast.setPreferredSize(new Dimension(mRightWidth, mFrameHeight));
		
		
		mLeftEditorView = LeftEditorView.getInstance(this);
		mPanelWest.getViewport().setView(mLeftEditorView);
		
		mRightEditorView = RightEditorView.getInstance();
		mPanelEast.getViewport().setView(mRightEditorView);
		
		mCenterEditorView = CenterEditorView.getInstance();
		mCenterEditorView.setBackground(mCenterbgColor);
		add(mCenterEditorView,"Center");
	}
	
	private void setEvent(){
		
	}

}
